﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Web.ASPxTreeList;
using olierFrm.WebFormDev;
using olierFrm.DataBase.FrameWork.StdQuery;
using olierFrm.WebFormDev.StdQuery;

namespace WebFormDev.Plugin
{
    public partial class DialogTreeSel : System.Web.UI.Page
    {
        
        protected void Page_PreInit(object sender, EventArgs e)
        {
            ManageSystem.IsLogin();
            ManageSystem.SetTheme(Page);
            //没有QueryName只显示菜单，为了重复利用该页面（系统首页和StdQuery）

        }

        protected string treeStyle;
        protected void Page_Load(object sender, EventArgs e)
        {
            treeStyle = "<style>.dxtlNode_" + Page.Theme + "{background-color: transparent;}.dxtlIndent_" + Page.Theme + ", .dxtlIndentWithButton_" + Page.Theme + "{background-color: transparent;}</style>";
            StdQuerySQL sqs = new StdQuerySQL(StdQuery.QueryName);
            foreach (var p in sqs.StdQueryParams)
            {
                sqs.SetParam(p.ParamName, Request.QueryString[p.ParamName]);
            }
            sqs.AddSystemParams();
            var dt = sqs.ExecuteSQL();
            if (dt.Columns.Contains("ParentNO"))
            {
                btnSearch.Visible = false;
                ASPxTreeList treeListSel = new ASPxTreeList();
                treeListSel.ID = "TreeListSel";
                treeListSel.Settings.ShowColumnHeaders = false;
                treeListSel.SettingsText.LoadingPanelText = "加载中，请稍候。";
                treeListSel.ParentFieldName = "ParentNO";
                treeListSel.KeyFieldName = "NO";
                treeListSel.AutoGenerateColumns = false;
                treeListSel.Columns.Add(new TreeListDataColumn() { FieldName = "ListName" });
                this.form1.Controls.Add(treeListSel);
                treeListSel.Settings.ShowColumnHeaders = false;
                treeListSel.SettingsBehavior.AllowFocusedNode = true;
                treeListSel.DataSource = dt;
                treeListSel.DataBind(); treeListSel.ExpandAll();
                treeListSel.Border.BorderStyle = BorderStyle.None;
            }
            else
            {

            }
            return;

        }
    }
}